﻿<storeApps:VisualStateAwarePage x:Class="GoG.WinRT.Views.SinglePlayerPage"
                           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                           xmlns:engine="using:GoG.Infrastructure.Engine"
                           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                           xmlns:sys="using:System"
                           xmlns:viewModels2="using:GoG.WinRT.ViewModels"
                           xmlns:winRt="using:GoG.WinRT"
                           xmlns:storeApps="using:Microsoft.Practices.Prism.StoreApps"
                           xmlns:behaviors="using:AdventureWorks.Shopper.Behaviors"
                           xmlns:controls="using:GoG.WinRT.Controls"
                           x:Name="pageRoot"
                           d:DataContext="{d:DesignInstance viewModels2:SinglePlayerPageViewModel}"
                           storeApps:ViewModelLocator.AutoWireViewModel="True"
                           mc:Ignorable="d">
    <!--d:DataContext="{d:DesignInstance viewModels2:SinglePlayerPageViewModel}"-->

    <Page.Resources>
        <winRt:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.Background>
            <ImageBrush AlignmentX="Left"
                        AlignmentY="Top"
                        ImageSource="/Assets/game.jpg"
                        Opacity=".4"
                        Stretch="UniformToFill" />
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="140" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        

        <!--  Back button and page title  -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton"
                    Command="{Binding GoBackCommand}"
                    Style="{StaticResource BackButtonStyle}" />
            <TextBlock x:Name="pageTitle"
                       Grid.Column="1"
                       Style="{StaticResource PageHeaderTextStyle}"
                       Text="The Game of Go" />
        </Grid>

        <Grid Grid.Row="1"
              Margin="120,0,0,0"
              VerticalAlignment="Top"
              x:Name="OptionsGrid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <!--<TextBlock Grid.Row="1"
                       Grid.Column="0"
                       Grid.ColumnSpan="2"
                       Margin="0,12,100,15"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       FontSize="30"
                       Text="Resume Current Game"
                       Visibility="{Binding IsActiveGame, FallbackValue=Visible,
                                            Converter={StaticResource BoolToVisibilityConverter}}" />-->
            <Button Grid.Row="2"
                    Grid.ColumnSpan="2"
                    Grid.Column="0"
                    Margin="0,0,0,25"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Top"
                    Command="{Binding ResumeCommand}"
                    Content="Resume Current Game"
                    FontSize="20"
                    Visibility="{Binding IsActiveGame,
                                         Converter={StaticResource BoolToVisibilityConverter}}" />

            <TextBlock Grid.Row="3"
                       Grid.ColumnSpan="2"
                       Margin="0,12,0,15"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       FontSize="26"
                       Text="Start New Game"
                       Visibility="{Binding IsActiveGame,
                                            Converter={StaticResource BoolToVisibilityConverter}}" />
            
            <TextBlock Grid.Row="4"
                       Grid.Column="0"
                       Margin="0,2,0,0"
                       HorizontalAlignment="Right"
                       VerticalAlignment="Center"
                       FontSize="18"
                       Text="Board Size:" />
            <ComboBox Grid.Row="4"
                      Grid.Column="1"
                      Width="160"
                      Margin="10,0,0,0"
                      HorizontalAlignment="Left"
                      DisplayMemberPath="Desc"
                      FontSize="18"
                      ItemsSource="{Binding Sizes}"
                      SelectedValue="{Binding BoardEdgeSize,
                                              Mode=TwoWay}"
                      SelectedValuePath="Value" />
            <TextBlock Grid.Row="5"
                       Grid.Column="0"
                       Margin="10,17,0,0"
                       HorizontalAlignment="Right"
                       VerticalAlignment="Center"
                       FontSize="18"
                       Text="Difficulty Level:" />
            <ComboBox Grid.Row="5"
                      Grid.Column="1"
                      Width="160"
                      Margin="10,15,0,0"
                      HorizontalAlignment="Left"
                      DisplayMemberPath="Desc"
                      FontSize="18"
                      ItemsSource="{Binding Difficulties}"
                      SelectedValue="{Binding DifficultyLevel,
                                              Mode=TwoWay}"
                      SelectedValuePath="Value" />
            <TextBlock Grid.Row="6"
                       Grid.Column="0"
                       Margin="0,17,0,0"
                       HorizontalAlignment="Right"
                       VerticalAlignment="Center"
                       FontSize="18"
                       Text="Color:" />
            <ComboBox Grid.Row="6"
                      Grid.Column="1"
                      Width="160"
                      Margin="10,15,0,0"
                      HorizontalAlignment="Left"
                      DisplayMemberPath="Desc"
                      FontSize="18"
                      ItemsSource="{Binding Colors}"
                      SelectedValue="{Binding Color,
                                              Mode=TwoWay}"
                      SelectedValuePath="Value" />

            <!--<TextBlock Grid.Row="7"
                       Grid.Column="0"
                       Margin="0,17,0,0"
                       HorizontalAlignment="Right"
                       VerticalAlignment="Center"
                       FontSize="18"
                       Text="Komi:" />-->
            <!--<TextBox x:Name="KomiTB"
                     Grid.Row="7"
                     Grid.Column="1"
                     Width="160"
                     Margin="10,15,0,0"
                     HorizontalAlignment="Left"
                     FontSize="18"
                     InputScope="Number"
                     Text="{Binding Komi,
                                    Mode=TwoWay}"
                     TextChanged="KomiTB_OnTextChanged" />-->

            <!--<TextBlock Grid.Row="8"
                       Grid.Column="0"
                       Margin="10,17,0,0"
                       HorizontalAlignment="Right"
                       VerticalAlignment="Center"
                       FontSize="18"
                       Text="Second Per Turn:" />
            <ComboBox Grid.Row="8"
                      Grid.Column="1"
                      Width="160"
                      Margin="10,15,0,0"
                      HorizontalAlignment="Left"
                      DisplayMemberPath="Desc"
                      FontSize="18"
                      ItemsSource="{Binding Seconds}"
                      SelectedValue="{Binding SecondsPerTurn,
                                              Mode=TwoWay}"
                      SelectedValuePath="Value" />-->

            <TextBlock Grid.Row="9"
                       Grid.Column="0"
                       Margin="0,17,0,0"
                       HorizontalAlignment="Right"
                       VerticalAlignment="Center"
                       FontSize="18"
                       Text="Your Name:" />
            <TextBox x:Name="NameTB"
                     MaxLength="20"
                     Grid.Row="9"
                     Grid.Column="1"
                     Width="160"
                     Margin="10,15,0,0"
                     HorizontalAlignment="Left"
                     FontSize="18"
                     Text="{Binding Name,
                                    Mode=TwoWay}"
                     TextChanged="NameTB_OnTextChanged" />

            <Button Grid.Row="10"
                    Grid.Column="1"
                    Width="100"
                    Margin="10,20"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    Command="{Binding PlayCommand}"
                    Content="Go!"
                    FontSize="18" />
        </Grid>

        <Border Grid.Row="1"
                Grid.RowSpan="8"
                Grid.ColumnSpan="8"
                Background="#D8000000"
                Visibility="{Binding IsBusy,
                                     Converter={StaticResource BoolToVisibilityConverter}}">
            <StackPanel Margin="0,0,0,50"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center">
                <ProgressRing Width="40"
                              Height="40"
                              HorizontalAlignment="Center"
                              Foreground="White"
                              IsActive="{Binding IsBusy}" />
                <TextBlock HorizontalAlignment="Center"
                           FontSize="26"
                           FontWeight="Normal"
                           Text="{Binding BusyMessage}" />
            </StackPanel>
        </Border>
    </Grid>
</storeApps:VisualStateAwarePage>
